﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BIZ;
using DAL;

namespace SinhNhat
{
    public partial class ServiceCategory : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Guid categoryID = new Guid(hdID.Value);
                CategoryServiceBIZ categoryBIZ = new CategoryServiceBIZ();
                ServiceBIZ serviceBIZ = new ServiceBIZ();

                var category = categoryBIZ.GetByID(categoryID);
                headerTitle.InnerText = lblTitle.Text = category.CategoryName;

                List<CategoryService> listChild = categoryBIZ.GetChildNode(categoryID.ToString());
                List<SERVICE> list = new List<SERVICE>();

                list.AddRange(serviceBIZ.GetByCategoryIDForUser(categoryID));

                for (int i = 0; i < listChild.Count; i++)
                {
                    list.AddRange(serviceBIZ.GetByCategoryIDForUser(listChild[i].CategoryServiceID));
                }

                CollectionPager1.DataSource = list;
                CollectionPager1.BindToControl = rptProduct;
                rptProduct.DataSource = CollectionPager1.DataSourcePaged;
                rptProduct.DataBind();
            }
        }
    }
}